Skip to content

Revert "feat: geofence-based geographic targeting for programs"#271

Merged
gonzalesedwin1123 merged 3 commits into
19.0from
revert-76-feature/program-geofence
Jul 2, 2026
Merged

Revert "feat: geofence-based geographic targeting for programs"#271
gonzalesedwin1123 merged 3 commits into
19.0from
revert-76-feature/program-geofence

Conversation

@jeremi

@jeremi jeremi commented Jul 2, 2026

Copy link
Copy Markdown
Member

Reverts #76

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the GIS and hazard reporting modules by removing the OGC API - Processes endpoints and replacing them with direct spatial query endpoints, reverting the CAP vocabulary severity migration back to a legacy selection scale, and reverting demographic disaggregation dimensions to boolean flags. Additionally, the Luzon geodata demo module has been removed in favor of a curated set of Philippine areas. The review feedback highlights a critical safety improvement in the map widget's draw event handler, recommending the use of optional chaining on the event object rather than an unguarded call to retrieve all features.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +215 to 221
function updateArea(e) {
console.log(e);
var data = self.draw.getAll();
self.props.record.update({
[self.props.name]: JSON.stringify(data.features[0].geometry),
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

When handling map draw events, avoid using unguarded getAll().features access. Instead, safely read the affected features directly from the event object using optional chaining (e.g., e?.features?.[0]) and guard on geometry before performing updates to prevent runtime errors.

Suggested change
function updateArea(e) {
console.log(e);
var data = self.draw.getAll();
self.props.record.update({
[self.props.name]: JSON.stringify(data.features[0].geometry),
});
}
function updateArea(e) {
const geometry = e?.features?.[0]?.geometry;
if (geometry) {
self.props.record.update({
[self.props.name]: JSON.stringify(geometry),
});
}
}
References
  1. When handling map draw events (such as draw.create or draw.update), avoid using unguarded getAll().features access. Instead, safely read the affected features directly from the event object using optional chaining (e.g., e?.features?.[0]) and guard on geometry before performing updates to prevent runtime errors.

registrants_by_area = {}
for registrant in registrants:
area_id = registrant.area_id.id
if area_id not in registrants_by_area:
# Count total registrants with area_id
total_count = Partner.search_count([("is_registrant", "=", True), ("area_id", "!=", False)])
# Get all registrants with an area_id
registrants = Partner.search(
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.26460% with 136 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.09%. Comparing base (1ba8bcc) to head (98ea5f8).
⚠️ Report is 4 commits behind head on 19.0.

Files with missing lines Patch % Lines
spp_api_v2_gis/routers/geofence.py 24.35% 59 Missing ⚠️
spp_api_v2_gis/routers/spatial_query.py 35.00% 26 Missing ⚠️
spp_api_v2_gis/services/layers_service.py 0.00% 19 Missing ⚠️
spp_api_v2_gis/routers/proximity.py 46.15% 14 Missing ⚠️
spp_api_v2_gis/routers/statistics.py 0.00% 8 Missing ⚠️
spp_api_v2_gis/services/spatial_query_service.py 81.81% 4 Missing ⚠️
spp_cel_domain/models/cel_translator.py 0.00% 2 Missing ⚠️
spp_drims/models/hazard_incident_area.py 60.00% 2 Missing ⚠️
spp_gis/operators.py 0.00% 1 Missing ⚠️
spp_gis_report/models/gis_report.py 90.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #271      +/-   ##
==========================================
- Coverage   75.31%   75.09%   -0.22%     
==========================================
  Files        1098     1093       -5     
  Lines       65317    63448    -1869     
==========================================
- Hits        49191    47649    -1542     
+ Misses      16126    15799     -327     
Flag Coverage Δ
spp_analytics 93.13% <ø> (ø)
spp_api_v2 79.78% <100.00%> (-0.14%) ⬇️
spp_api_v2_change_request 66.41% <ø> (ø)
spp_api_v2_cycles 70.65% <ø> (ø)
spp_api_v2_data 77.43% <ø> (ø)
spp_api_v2_gis 71.52% <47.15%> (-12.75%) ⬇️
spp_base_common 90.26% <ø> (ø)
spp_cel_domain 62.23% <33.33%> (-0.59%) ⬇️
spp_demo 73.54% <ø> (-0.09%) ⬇️
spp_drims 80.82% <60.00%> (-0.19%) ⬇️
spp_drims_sl_demo 68.91% <ø> (-0.17%) ⬇️
spp_gis 74.09% <0.00%> (-1.21%) ⬇️
spp_gis_report 82.60% <92.85%> (+4.40%) ⬆️
spp_hazard 99.59% <100.00%> (+1.98%) ⬆️
spp_hazard_programs 97.14% <ø> (ø)
spp_metric_service 89.58% <100.00%> (+0.66%) ⬆️
spp_mis_demo_v2 73.61% <ø> (+5.52%) ⬆️
spp_programs 65.27% <ø> (ø)
spp_registry 86.83% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_api_v2/middleware/auth.py 75.75% <100.00%> (-0.37%) ⬇️
spp_api_v2/models/fastapi_endpoint_registry.py 93.93% <ø> (-0.35%) ⬇️
spp_api_v2/schemas/__init__.py 100.00% <100.00%> (ø)
spp_api_v2/schemas/bundle.py 100.00% <100.00%> (ø)
spp_api_v2_gis/__manifest__.py 0.00% <ø> (ø)
spp_api_v2_gis/models/__init__.py 100.00% <ø> (ø)
spp_api_v2_gis/models/api_client_scope.py 100.00% <ø> (ø)
spp_api_v2_gis/models/fastapi_endpoint.py 100.00% <100.00%> (ø)
spp_api_v2_gis/routers/__init__.py 100.00% <100.00%> (ø)
spp_api_v2_gis/routers/ogc_features.py 86.44% <100.00%> (+19.44%) ⬆️
... and 37 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d38ff9d7a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Params ordered to match SQL: filter params, geometry, population filter
params = filter_params + [geometry_json] + pop_params
# Add geometry parameter at the beginning
params = [geometry_json] + params[1:]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve SQL parameter order for filtered spatial queries

When filters.is_group is provided, the generated SQL has the p.is_group = %s placeholder before the ST_GeomFromGeoJSON(%s) placeholder, but this line still sends the GeoJSON value first. That binds a JSON string to the boolean comparison, causing the coordinate query to error and fall back to the area path; in deployments relying on point coordinates or with incomplete area polygons, filtered /gis/query/statistics results become empty or inaccurate instead of using the matching coordinates.

Useful? React with 👍 / 👎.

HTTPException: 403 if missing scope, 422 if validation fails
"""
# Check geofence scope
if not api_client.has_scope("gis", "geofence"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the geofence action registered for write endpoints

This write endpoint still requires api_client.has_scope("gis", "geofence"), but the same change removes the geofence action from spp.api.client.scope's selection. After an upgrade, geofence-only scopes are no longer valid/can be cascaded away, and admins can only satisfy this check by granting broad gis:all; clients intended to create/delete geofences without full GIS access will receive 403s.

Useful? React with 👍 / 👎.

Comment thread spp
Comment on lines +477 to 479
# Verify the module is actually installed now
state = _get_module_state(profile, module_name)
if state == "installed":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check one module when waiting on comma installs

For custom demo values such as ./spp start --wipe --demo=a,b, ODOO_INIT_MODULES is correctly set to the comma-separated list, but this check now searches ir.module.module for the literal name a,b. Odoo stores module names separately, so _get_module_state returns NOT_FOUND and the CLI waits until timeout even after the modules finish installing; use one module from the list, as the previous code did, when verifying completion.

Useful? React with 👍 / 👎.

Mainline depends on this piece of #76: PR #160 (fix/name-format-on-create-write)
overwrites explicit names on create/write, and spp_demo's demo-stories tests
assert explicit names survive. The guard added in #76 (skip formatting when
vals contains an explicit name) is what keeps spp_demo green on 19.0.
Reverting it fails CI (3 failures in spp_demo test_demo_stories), so this
bugfix stays; everything else from #76 remains reverted and will be re-landed
in scoped PRs.
@gonzalesedwin1123

Copy link
Copy Markdown
Member

CI was red on this revert: test (spp_demo) failed with 3 assertions in test_demo_stories (explicit individual names being reformatted, e.g. 'INDIVIDUAL PERSON, TEST' != 'Test Individual Person').

Root cause: mainline already depends on one piece of #76 — the spp_registry guard that preserves an explicitly-written name (needed since #160 introduced name formatting on create/write; spp_demo's demo-stories tests assert explicit names survive).

Pushed 1f9d14e3 which keeps that two-file bugfix (spp_registry/models/individual.py + its regression test) out of the revert. Everything else from #76 remains reverted and will be re-landed in scoped, description-consistent PRs (plan: 10 branches across 5 dependency waves; the hazard severity re-land will include the missing migration for the v19.0.2.0.0 upgrade path).

…ame fix

test_search_service asserts registrant names; with the spp_registry
explicit-name preservation retained (1f9d14e), the #76 version of these
assertions ('Alice Johnson' rather than 'JOHNSON, ALICE') is the correct
expectation. Reverting only the test file broke test (spp_api_v2) on CI.
@gonzalesedwin1123 gonzalesedwin1123 merged commit 91dacfb into 19.0 Jul 2, 2026
33 of 34 checks passed
@gonzalesedwin1123 gonzalesedwin1123 deleted the revert-76-feature/program-geofence branch July 2, 2026 14:45
gonzalesedwin1123 added a commit that referenced this pull request Jul 2, 2026
Bring the branch up to date with 19.0 (30 commits, incl. the geofence
partial-revert #271). Conflict in spp_hazard/views/hazard_incident_views.xml
resolved by adopting 19.0's Impacts-page rework while preserving this PR's
security `groups=` gate on the Impacts page and the 'Affected' stat button.
Auto-merged manifest (kept our 2.0.3 security bump) and tests/__init__.py
(kept our test_acl_group_user import, took 19.0's removal of test_alert_ingestion).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants